﻿package net.pezzato.localization {
	import flash.net.URLLoader;
	import flash.net.URLRequest;
	import flash.events.Event;
	import flash.events.EventDispatcher;
	public class TranslatorLoader extends EventDispatcher {
		public static const READY:String = "Translator is ready";
		public static const LOADED:String = "TranslatorLoader has loaded loanguage";
		private static var langXml_s:XML;
		private var ready_:Boolean = false;
		public function load(lang:String) {
			var loader:URLLoader = new URLLoader();
			var request:URLRequest = new URLRequest("lang/" + lang + ".xml");
			loader.addEventListener(Event.COMPLETE, onLangLoaded);
			loader.load(request);
		}
		public function get langXml():XML {
			return langXml_s;
		}
		public function set ready(ready:Boolean) {
			ready_ = ready;
			dispatchEvent(new Event(READY));
		}
		private function onLangLoaded(event:Event) {
			langXml_s = new XML(event.target.data);
			dispatchEvent(new Event(LOADED));
		}
	}
}